<?php
    class Login extends CI_Controller{
        function __construct() {
            parent::__construct();
            $this->load->model('user','',true);
        }
        function index()
        {
            $this->load->view('login_view');    
        }
        function check_database(){
            //GET FORM DATA BY POST METHOD
            $username = $this->input->post('username');
            $password = $this->input->post('password');
            //GET DATA FORM LOGIN MODEL FUNCTION
            $query = $this->user->login($username,$password);
            
            if($query == TRUE)
            {
                //IF USER EXISTED
                $session_username = array('username' => $username);
                $this->session->set_userdata('logged_in',$session_username);
                $this->load->view('home_view');
            }
            else
            {
                //USER DOES NOT EXISTED
                $this->load->view('login_view'); 
            }
        }
    }
?>
